package com.soft.springhrms.utils;

import javax.servlet.http.HttpServletRequest;

public class IPUtil {
    public static String getClientIp(HttpServletRequest request) {
        String clientIp = request.getHeader("X-Forwarded-For");
        if (clientIp == null || clientIp.isEmpty()) {
            clientIp = request.getRemoteAddr();
        } else {
            String[] ipArray = clientIp.split(",");
            clientIp = ipArray[0];
        }
        return clientIp;
    }
}
